import os

proc createUrlFile(filePath: string, targetUrl: string): void =
  try:
    var file = open(filePath&".url", fmWrite)
    file.writeLine("[InternetShortcut]")
    file.writeLine("URL=" & targetUrl)
    file.close()
    echo "已成功创建 .url 文件: " & filePath
  except Exception:
    echo "创建文件时出错: " & getCurrentExceptionMsg()


when isMainModule:
  if paramCount() != 2:
    echo "请提供两个参数，第一个为文件名，第二个为目标 URL。"
    quit(1)

  let filePath = paramStr(1)
  let targetUrl = paramStr(2)
  createUrlFile(filePath, targetUrl)
    